//app.js
App({
  onLaunch: function () {
  },
  globalData: {
    shareTitle:'官方服务导航。新时代，共享未来！',
    sharePath: '/pages/index/index',
    isIphoneX: false,
    varsion:'',
    isOldSDK:'true',
    lang:'zh',
    loadTime:0,
    url: 'https://ciie.3tiworld.com/api/',
    imageUrl: 'https://ciie.3tiworld.com/',
    // imageUrl:'https://ciie.luoyibo.com',
    // url:'https://ciie.luoyibo.com/api/',
    // imageUrl:'https://ciie.luoyibo.com',
    // url:'http://www.jinbohui.com/api/',
    // imageUrl:'http://www.jinbohui.com', 
  },
  onShow: function () {
    let that = this;
    wx.getSystemInfo({
      success: res => {
        console.log(res)
        let modelmes = res.model;
        if (modelmes.search('iPhone X') != -1) {
          that.globalData.isIphoneX = true
        }
        that.globalData.version = res.version;
        if (that.compareVersion(res.SDKVersion,'2.1.0') >= 0){
          that.globalData.isOldSDK = false;
        }
        console.log(that.globalData);
      }
    });
  },
  compareVersion:function (v1, v2) {
    console.log(v1,v2);
    v1 = v1.split('.')
    v2 = v2.split('.')
    var len = Math.max(v1.length, v2.length)

    while(v1.length <len) {
        v1.push('0')
      }
    while(v2.length <len) {
        v2.push('0')
      }
    for(var i = 0; i<len; i++) {
    var num1 = parseInt(v1[i])
    var num2 = parseInt(v2[i])

    if (num1 > num2) {
      return 1
    } else if (num1 < num2) {
      return -1
    }
  }
    return 0
  }

})